package com.solcoo.service;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.solcoo.dao.RechargeDao;
import com.solcoo.dao.UseromrelaDao;
import com.solcoo.dao.YongHuDao;
import com.solcoo.pojo.RechargeInfo;
import com.solcoo.pojo.Useromrela;
import com.solcoo.pojo.YongHu;

@Service
public class RechargeService {

	@Resource
    private RechargeDao rechargeDao;
	@Resource
    private YongHuDao yongHuDao;
    @Resource
    private UseromrelaDao useromrelaDao;

    
    public void addRechargeInfo(RechargeInfo ri) throws Exception {
    	rechargeDao.addRechargeInfo(ri);
    }

    
    public void deleteRechargeInfo(long rechargeInfoId) throws Exception {
    	rechargeDao.deleteRechargeInfo(rechargeInfoId);
    }

    
    public List<RechargeInfo> selectRechargeInfo(String merchantId) throws Exception {
    	YongHu yh = yongHuDao.selectUserByYonghum(merchantId);
    	if(yh.getLeixing()!=null && "3".equals(yh.getLeixing())) {
    		Useromrela ur = useromrelaDao.getEnabledEmployee(merchantId);
    		if(ur != null) {
    			merchantId = ur.getOwnerid();
    		} else {
    			return null;
    		}
    	}
        return rechargeDao.selectRechargeInfo(merchantId);
    }

}
